ストリップチャート
Contents
7. ストリップチャート¶
7.1. 概要¶
ストリップチャートとは,
7.2. Plotlyによる作図方法¶
7.3. MADB Labを用いた作図例¶
7.3.1. 下準備¶
import pandas as pd
import plotly.express as px
import warnings
warnings.filterwarnings('ignore')
# 前処理の結果,以下に分析対象ファイルが格納されていることを想定
PATH_DATA = '../../data/preprocess/out/episodes.csv'
# Jupyter Book用のPlotlyのrenderer
RENDERER = 'plotly_mimetype+notebook'
def show_fig(fig):
"""Jupyter Bookでも表示可能なようRendererを指定"""
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
fig.show(renderer=RENDERER)
df = pd.read_csv(PATH_DATA)
7.3.2. 雑誌別・作品別の合計連載週数¶
df_plot = \
df.value_counts(['mcname', 'cname']).reset_index(name='weeks')
# X軸の表示順を調整
df_plot = df_plot.sort_values('mcname', ignore_index=True)
fig = px.strip(
df_plot, x='mcname', y='weeks',
title='雑誌別・作品別の合計連載週数')
show_fig(fig)
fig.update_yaxes(range=[0, 200])
show_fig(fig)
7.3.3. 雑誌別・作者別の合計連載週数¶
df_plot = \
df.value_counts(['mcname', 'creator']).reset_index(name='weeks')
# X軸の表示順を調整
df_plot = df_plot.sort_values('mcname', ignore_index=True)
fig = px.strip(
df_plot, x='mcname', y='weeks',
title='雑誌別・作者別の合計連載週数')
show_fig(fig)
fig.update_yaxes(range=[0, 200])
show_fig(fig)